<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">
    
    <title>Dynamic Table</title>
    
    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>
    
    <?php $this->load->view('library/left');?>
    
    <!-- main content start-->
    <div class="main-content" >
        
        <?php $this->load->view('library/top');?>
        
        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                产品列表
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Dashboard</a>
                </li>
                <li>
                    <a href="#">Data Tables</a>
                </li>
                <li class="active"> Dynamic Table </li>
            </ul>
        </div>
        <!-- page heading end-->
        
        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <?php $this->load->view('library/search');?>
                    <section class="panel">
                        <div class="panel-body">
                            
                            <div class="adv-table">
                                <table  class="display table table-bordered table-striped" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="3%">#</th>
                                        <th width="5%">标题</th>
                                        <th width="10%" class="hidden-phone">内容</th>
                                        <th width="5%" class="hidden-phone">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($shopify_cat as $item): ?>
                                        <tr class="gradeX">
                                            <td><?php echo $item['id'];?></td>
                                            <td><?php echo $item['title'];?></td>
                                            <td class="center hidden-phone">
												<?php foreach (json_decode($item['text'],true) as $v): ?>
													<span style="float: left;"><?php echo $v['column']?></span><span><?php echo $v['relation']?></span><span style="float: right;"><?php echo $v['condition']?></span><br>
												<?php endforeach;?>
                                            </td>
                                            <td class="hidden-phone">
                                                <a class="btn btn-xs btn-info" href="<?php echo base_url('siteweb/shopify_cat_save/id/'. $item['id']);?>">编辑</a>
                                                <a class="btn btn-xs btn-info a-ajax" href="<?php echo base_url('siteweb/shopify_cat_del/id/'. $item['id']);?>">删除</a>
                                            </td>
                                        </tr>
                                    <?php endforeach;?>
                                    </tbody>
                                </table>
                            </div>
                            <button class="btn btn-info shangchuan" href="<?php echo base_url('siteweb/aa');?>" type="submit" style="margin-left: 35%;">上传</button>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->
        
        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->
    
    
    </div>
    <!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>
<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>
<script type="text/javascript">
    $('.a-ajax').click(function () {

        var url = $(this).attr('href');
        swal({
            title: '确定要删除吗?',
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then(function (result) {
            if (result.value) {
                $.get(url, {is_ajax: 1}, function (data) {
                    swal({
                        title: data.info,
                        text: '2秒后关闭',
                        type: data.status,
                        allowOutsideClick: false,
                        timer: data.stop ? data.stop : 1500,
                        showConfirmButton: false
                    }).then(function(isConfirm) {
                        location.reload();
                    });

                }, 'json');
            }
        })


        return false;
    });
    $ (".shangchuan").on ("click", function () {
        swal ({
            title: '上传shopify分类',
            input: 'select',
            inputOptions: <?php echo $siteweb_json; ?>,
            showCancelButton: true,
            allowOutsideClick: false,
            confirmButtonText: 'Submit',
            inputPlaceholder: '请选择网站',
            inputValidator: function (value) {
                if (!value) {
                    return '未选择任何网站!';
                }
            },
            preConfirm: function preConfirm(value) {

                swal ({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post ("<?php echo base_url('Siteweb/up_shopify_goods_cat');?>", {
                    web_id: value,
                }, function (data) {
                    return data;
                }, 'json');
            }
        }).then (function (result) {
            if (result.value) {
                var data = result.value;
                swal ({
                    type: data.status,
                    title: data.info
                }).then (function (isConfirm) {
                    location.reload ();
                });
            }
        });

        return false;
    });
</script>
</body>
</html>
